home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / win / csh_doc.zip / HOW2DEMO.TXT < prev    next >
Text File  |  1994-03-15  |  6KB  |  121 lines

  1.  
  2.                     How to Demo Hamilton C shell
  3.  
  4.  
  5.  
  6.    To set up the Hamilton C shell demo, first install it just as
  7. described in the manual on pages 11 and 12, including setting up
  8. the environmental variables (HOME, PATH, COLORS, TABS, ADDITIONS,
  9. etc.) in the control panel as shown in the manual.
  10.  
  11.    A good demonstration might go as follows.  What you type is
  12. shown in Courier Bold, machine responses are in Courier and my
  13. comments are in italics.
  14.  
  15. 1 C% cd \hamilton   Go to the Hamilton C shell directory
  16. 2 C% ls -l          List the contents of the directory.  Notice
  17.                     how subdirectories are shown highlighted.  The
  18.                     C shell makes extensive use of color and all
  19.                     colors are completely user-customizable.
  20. D----  Apr 14  5:00          -  bin
  21. D----  Apr 14  5:00          -  samples
  22. -----  Apr 14  5:00       1712  login.csh
  23. -----  Apr 14  5:00       5215  readme
  24. ---A-  May 20  2:00      31410  readme.too
  25. -----  Apr 14  5:00       4369  startup.csh
  26. 3 C% ls bin         List the bin directory, showing all the
  27.                     utilities.  Notice that all the usual
  28.                     favorites such as grep, fgrep, head, tail,
  29.                     etc., are included.
  30. binedit.exe   dskread.exe   hrm.exe       split.exe     uniq.exe
  31. cat.exe       dskwrite.exe  ls.exe        strings.exe   ver.csh
  32. chmod.exe     dt.exe        mkdir.exe     sum.exe       vl.exe
  33. cp.exe        du.exe        mv.exe        tabs.exe      wc.exe
  34. csh.exe       fgrep.exe     newer.exe     tail.exe      whereis.csh
  35. cut.exe       grep.exe      older.exe     tar.exe       xd.exe
  36. des.exe       head.exe      pwd.exe       tee.exe
  37. diff.exe      hlabel.exe    rmdir.exe     touch.exe
  38. dim.exe       hmore.exe     sed.exe       tr.exe
  39. 4 C% alias mi       It has aliases -- here's an alias for the
  40.                     more filter, starting it up in interactive
  41.                     mode (so it'll first clear the screen and
  42.                     stay around even if it's less than a
  43.                     screenful.)
  44. mi           more -i
  45. 5 C% grep -h | mi   Everything always has online help with the -h
  46.                     option.
  47.         Regular expression pattern search of text files,
  48.         Release 2.1
  49.  
  50. Usage:  grep [-hcilnqsv-] [-f ptrnfile] [ pattern ] [ file1 file2
  51. ...]
  52.  
  53.    grep uses special patterns called regular expressions to filter
  54.    what it reads from stdin or from any files you specify.
  55. :
  56. --- more --- (Press H for Help)  _ Notice we can scroll up and
  57.                     down with the arrow keys (Do it).  And the
  58.                     more filter itself has online help by
  59.                     pressing H.  (Press H to show it, then press
  60.                     any key to exit the help screen, followed
  61.                     by Q or ESC to get out.)
  62. 6 C% time factor 12341234     The C shell is a powerful scripting
  63.                     language.  Here's an example, factoring a large
  64.                     number.  Notice that we can time any command
  65.                     to see how long it takes.
  66. 2
  67. 73
  68. 137
  69. 617
  70. 0:00:01.37
  71. 7 C% whereis factor This is actually a C shell script.  We can
  72.                     find it with the whereis command.
  73. c:\hamilton\samples\factor.csh
  74. 8 C% mi `!!`        (Note that this is typed with BACKQUOTES,
  75.                     located next to the numeric one.)  Let's
  76.                     go browse it.  Here, the !! (pronounced
  77.                     bang-bang) part means pick up the text of
  78.                     the previous command (the whereis factor).
  79.                     The backquotes mean run what's inside there
  80.                     and paste the output (the
  81.                     c:\hamilton\samples\whereis.csh result) back
  82.                     onto the command line.  That's called
  83.                     command substitution, passing the filename
  84.                     as an argument to mi, which we saw was the
  85.                     alias for more.  So what we'll do is browse
  86.                     that script.
  87.  
  88. proc factor(n)      Notice that this C shell has procedures,
  89.    if (n > 3) then
  90.       for i = 2 to floor(sqrt(n)) do    a genuine numeric for
  91.                                         loop, built-in functions
  92.                                         like floor and square root,
  93.          if (n % i == 0) then
  94.             echo $i
  95.             return factor(n//i)         and procedures can even be
  96.                                         recursive.  Not surprisingly,
  97.                                         a lot of customers are using
  98.                                         Hamilton C shell with thousands
  99.                                         of lines of scripts.  For
  100.                                         example, Sybase uses it to
  101.                                         run the build for SQL Server,
  102.                                         Microsoft's languages group
  103.                                         uses it to run nightly regression
  104.                                         tests, etc.
  105.          end
  106.       end
  107.    end
  108.    return n
  109. end
  110. :
  111. 9 C% echo \<Ctrl-D> Finally, the C shell has a lot of "creature
  112.                     comforts" such as filename completion and
  113.                     command line editing.  Here, e.g., we'll
  114.                     expand in-place all the names of the files
  115.                     in the root.  So for folks coming from
  116.                     a UNIX background -- or anyone looking simply
  117.                     for a more powerful scripting or development
  118.                     environment, Hamilton C shell can be very
  119.                     attractive, offering instant productivity
  120.                     gains.
  121.